<template>
  <el-dialog title="订单状态" :visible.sync="dialogVisible" width="1200px" :close-on-click-modal="false"  :modal-append-to-body="false" v-drag2anywhere>
    <el-form v-model="formData" label-width="80px">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="采购单号:">
            {{formData.reqcode}}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="供应商:">
            {{formData.seller}}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="支付状态:">
            {{formData.paidstatus==0?"未支付":(formData.paidstatus==1?"已支付":"部分支付")}}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="订单总额:">
            ¥ {{parseFloat(formData.sum+"").toFixed(2)}}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="客户:">
            {{formData.client}}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="业务员:">
            {{formData.requester}}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="所属账套:">{{formData.buyer}}</el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="订单状态:">
              <el-select v-model="closed" placeholder="订单状态">
                <el-option label="正常" value="0"></el-option>
                <el-option label="取消" value="1"></el-option>
              </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="18">
            <el-form-item label="状态备注:">
              <el-input type="textarea" v-model="formData.closedmemo" rows="5" placeholder="订单状态备注"></el-input>
            </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <div slot="footer" class="dialog-footer">
    	<el-button size="medium" @click="dialogVisible=false">取消</el-button>
      <el-button type="primary" size="medium" @click="handleSave">保存状态</el-button>
    </div>

  </el-dialog>
</template>

<script>
  export default {
    data() {
      return {
        index:-1,
        formData:{
          closed:-1,
          closedmemo:'',
        },
        closed:-1,
        dialogVisible: false
      }
    },
    methods:{
      init(index,data){
          this.index=index;
          this.formData=data;
          this.closed=this.formData.closed;
      },
      handleSave(){
          var params={
            status:this.closed,
            reqcode:this.formData.reqcode,
            memo:this.formData.closedmemo
          }

          this.axios.post("/api/admin/buylist/update_status",params).then(res => {
            if (res.status == 200 && res.data.code == 1) {
                this.$message.success(res.data.msg);
                this.formData.status=this.status;
                this.$emit("updated",this.index,params);
                this.dialogVisible=false;
            }else{
              this.$message.error(res.data.msg);
            }
          })



      }
    }
  }
</script>

<style>
</style>
